{% extends 'layout_user.html' %}

{% block content %}
    <div class="container">
        <h3 class="panel-title"> 个人资料 </h3>
        <div class="panel-body">
            <div class="table-responsive">
                <table class="table table-bordered table-striped">
                    <colgroup>
                        <col class="col-xs-1">
                        <col class="col-xs-7">
                    </colgroup>
                    <thead>
                    <tr>
                        <th>用户信息</th>
                        <th>内容</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <th>学号</th>
                        <td id="student-id"></td>
                    </tr>
                    <tr>
                        <th>姓名</th>
                        <td id="student-name"></td>
                    </tr>
                    <tr>
                        <th>密码</th>
                        <td id="student-password"></td>
                    </tr>
                    <tr>
                        <th>性别</th>
                        <td id="student-gender"></td>
                    </tr>
                    <tr>
                        <th>所属部门</th>
                        <td id="student-department"></td>
                    </tr>
                    <tr>
                        <th>IP地址</th>
                        <td id="student-ip"></td>
                    </tr>
                    <tr>
                        <th>上次签到时间</th>
                        <td id="last-signin-time"></td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <button onclick="goBack()">返回</button>
        </div>
    </div>
{% endblock %}

{% block js %}
    <script>
        function goBack() {
            // 使用JavaScript的history对象的go方法实现上一步跳转
            window.history.back();
        }
    </script>
    <script type="text/javascript">

        $(function () {

            initInfo();

        })

        function initInfo() {
            $.ajax({
                url: '/info/list/',  // 用于获取学生数据
                method: 'post',
                success: function (res) {
                    if (res.status) {
                        // 在成功获取数据后，将数据填充到相应的 <td> 标签中
                    $('#student-id').text(res.data["student_id"]);
                    $('#student-name').text(res.data["student_name"]);
                    $('#student-password').text(res.data["student_password"]);
                    $('#student-gender').text(res.data["student_gender"]);
                    $('#student-department').text(res.data["student_department"]);
                    $('#student-ip').text(res.data["student_ip"]);
                    $('#last-signin-time').text(res.data["last_signin_time"]);
                    }

                }
            });
        }


    </script>
{% endblock %}
